using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Domain.ExpandEntity
{
    /// <summary>
    /// 自我关联的表行
    /// </summary>
    public class SelfRelationRow
    {
        /// <summary>
        /// ID
        /// </summary>
        public int ID { get; set; }
        /// <summary>
        /// 父级ID
        /// </summary>
        public int? ParentID { get; set; }
        /// <summary>
        /// 深度（无父级则深度为零）
        /// </summary>
        public int Depth { get; set; }
        /// <summary>
        /// 父级路径
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 父级路径解析成祖先ID集合
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static IEnumerable<int> ParsePath(string path)
        {
            if (!string.IsNullOrEmpty(path))
                return path.Split(',').Select(a => Convert.ToInt32(a));
            return null;
        }
    }
}
